home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / plain.bst < prev    next >
Text File  |  1988-01-22  |  19KB  |  1,098 lines

  1. % BibTeX standard bibliography style `plain'
  2.     % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
  3.     % Copyright (C) 1985, all rights reserved.
  4.     % Copying of this file is authorized only if either
  5.     % (1) you make absolutely no changes to your copy, including name, or
  6.     % (2) if you do make changes, you name it something other than
  7.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  8.     % This restriction helps ensure that all standard styles are identical.
  9.     % The file btxbst.doc has the documentation for this style.
  10.  
  11. ENTRY
  12.   { address
  13.     author
  14.     booktitle
  15.     chapter
  16.     edition
  17.     editor
  18.     howpublished
  19.     institution
  20.     journal
  21.     key
  22.     month
  23.     note
  24.     number
  25.     organization
  26.     pages
  27.     publisher
  28.     school
  29.     series
  30.     title
  31.     type
  32.     volume
  33.     year
  34.   }
  35.   {}
  36.   { label }
  37.  
  38. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  39.  
  40. FUNCTION {init.state.consts}
  41. { #0 'before.all :=
  42.   #1 'mid.sentence :=
  43.   #2 'after.sentence :=
  44.   #3 'after.block :=
  45. }
  46.  
  47. STRINGS { s t }
  48.  
  49. FUNCTION {output.nonnull}
  50. { 's :=
  51.   output.state mid.sentence =
  52.     { ", " * write$ }
  53.     { output.state after.block =
  54.     { add.period$ write$
  55.       newline$
  56.       "\newblock " write$
  57.     }
  58.     { output.state before.all =
  59.         'write$
  60.         { add.period$ " " * write$ }
  61.       if$
  62.     }
  63.       if$
  64.       mid.sentence 'output.state :=
  65.     }
  66.   if$
  67.   s
  68. }
  69.  
  70. FUNCTION {output}
  71. { duplicate$ empty$
  72.     'pop$
  73.     'output.nonnull
  74.   if$
  75. }
  76.  
  77. FUNCTION {output.check}
  78. { 't :=
  79.   duplicate$ empty$
  80.     { pop$ "empty " t * " in " * cite$ * warning$ }
  81.     'output.nonnull
  82.   if$
  83. }
  84.  
  85. FUNCTION {output.bibitem}
  86. { newline$
  87.   "\bibitem{" write$
  88.   cite$ write$
  89.   "}" write$
  90.   newline$
  91.   ""
  92.   before.all 'output.state :=
  93. }
  94.  
  95. FUNCTION {fin.entry}
  96. { add.period$
  97.   write$
  98.   newline$
  99. }
  100.  
  101. FUNCTION {new.block}
  102. { output.state before.all =
  103.     'skip$
  104.     { after.block 'output.state := }
  105.   if$
  106. }
  107.  
  108. FUNCTION {new.sentence}
  109. { output.state after.block =
  110.     'skip$
  111.     { output.state before.all =
  112.     'skip$
  113.     { after.sentence 'output.state := }
  114.       if$
  115.     }
  116.   if$
  117. }
  118.  
  119. FUNCTION {not}
  120. {   { #0 }
  121.     { #1 }
  122.   if$
  123. }
  124.  
  125. FUNCTION {and}
  126. {   'skip$
  127.     { pop$ #0 }
  128.   if$
  129. }
  130.  
  131. FUNCTION {or}
  132. {   { pop$ #1 }
  133.     'skip$
  134.   if$
  135. }
  136.  
  137. FUNCTION {new.block.checka}
  138. { empty$
  139.     'skip$
  140.     'new.block
  141.   if$
  142. }
  143.  
  144. FUNCTION {new.block.checkb}
  145. { empty$
  146.   swap$ empty$
  147.   and
  148.     'skip$
  149.     'new.block
  150.   if$
  151. }
  152.  
  153. FUNCTION {new.sentence.checka}
  154. { empty$
  155.     'skip$
  156.     'new.sentence
  157.   if$
  158. }
  159.  
  160. FUNCTION {new.sentence.checkb}
  161. { empty$
  162.   swap$ empty$
  163.   and
  164.     'skip$
  165.     'new.sentence
  166.   if$
  167. }
  168.  
  169. FUNCTION {field.or.null}
  170. { duplicate$ empty$
  171.     { pop$ "" }
  172.     'skip$
  173.   if$
  174. }
  175.  
  176. FUNCTION {emphasize}
  177. { duplicate$ empty$
  178.     { pop$ "" }
  179.     { "{\em " swap$ * "}" * }
  180.   if$
  181. }
  182.  
  183. INTEGERS { nameptr namesleft numnames }
  184.  
  185. FUNCTION {format.names}
  186. { 's :=
  187.   #1 'nameptr :=
  188.   s num.names$ 'numnames :=
  189.   numnames 'namesleft :=
  190.     { namesleft #0 > }
  191.     { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
  192.       nameptr #1 >
  193.     { namesleft #1 >
  194.         { ", " * t * }
  195.         { numnames #2 >
  196.         { "," * }
  197.         'skip$
  198.           if$
  199.           t "others" =
  200.         { " et~al." * }
  201.         { " and " * t * }
  202.           if$
  203.         }
  204.       if$
  205.     }
  206.     't
  207.       if$
  208.       nameptr #1 + 'nameptr :=
  209.       namesleft #1 - 'namesleft :=
  210.     }
  211.   while$
  212. }
  213.  
  214. FUNCTION {format.authors}
  215. { author empty$
  216.     { "" }
  217.     { author format.names }
  218.   if$
  219. }
  220.  
  221. FUNCTION {format.editors}
  222. { editor empty$
  223.     { "" }
  224.     { editor format.names
  225.       editor num.names$ #1 >
  226.     { ", editors" * }
  227.     { ", editor" * }
  228.       if$
  229.     }
  230.   if$
  231. }
  232.  
  233. FUNCTION {format.title}
  234. { title empty$
  235.     { "" }
  236.     { title "t" change.case$ }
  237.   if$
  238. }
  239.  
  240. FUNCTION {n.dashify}
  241. { 't :=
  242.   ""
  243.     { t empty$ not }
  244.     { t #1 #1 substring$ "-" =
  245.     { t #1 #2 substring$ "--" = not
  246.         { "--" *
  247.           t #2 global.max$ substring$ 't :=
  248.         }
  249.         {   { t #1 #1 substring$ "-" = }
  250.         { "-" *
  251.           t #2 global.max$ substring$ 't :=
  252.         }
  253.           while$
  254.         }
  255.       if$
  256.     }
  257.     { t #1 #1 substring$ *
  258.       t #2 global.max$ substring$ 't :=
  259.     }
  260.       if$
  261.     }
  262.   while$
  263. }
  264.  
  265. FUNCTION {format.date}
  266. { year empty$
  267.     { month empty$
  268.     { "" }
  269.     { "there's a month but no year in " cite$ * warning$
  270.       month
  271.     }
  272.       if$
  273.     }
  274.     { month empty$
  275.     'year
  276.     { month " " * year * }
  277.       if$
  278.     }
  279.   if$
  280. }
  281.  
  282. FUNCTION {format.btitle}
  283. { title emphasize
  284. }
  285.  
  286. FUNCTION {tie.or.space.connect}
  287. { duplicate$ text.length$ #3 <
  288.     { "~" }
  289.     { " " }
  290.   if$
  291.   swap$ * *
  292. }
  293.  
  294. FUNCTION {either.or.check}
  295. { empty$
  296.     'pop$
  297.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  298.   if$
  299. }
  300.  
  301. FUNCTION {format.bvolume}
  302. { volume empty$
  303.     { "" }
  304.     { "volume" volume tie.or.space.connect
  305.       series empty$
  306.     'skip$
  307.     { " of " * series emphasize * }
  308.       if$
  309.       "volume and number" number either.or.check
  310.     }
  311.   if$
  312. }
  313.  
  314. FUNCTION {format.number.series}
  315. { volume empty$
  316.     { number empty$
  317.     { series field.or.null }
  318.     { output.state mid.sentence =
  319.         { "number" }
  320.         { "Number" }
  321.       if$
  322.       number tie.or.space.connect
  323.       series empty$
  324.         { "there's a number but no series in " cite$ * warning$ }
  325.         { " in " * series * }
  326.       if$
  327.     }
  328.       if$
  329.     }
  330.     { "" }
  331.   if$
  332. }
  333.  
  334. FUNCTION {format.edition}
  335. { edition empty$
  336.     { "" }
  337.     { output.state mid.sentence =
  338.     { edition "l" change.case$ " edition" * }
  339.     { edition "t" change.case$ " edition" * }
  340.       if$
  341.     }
  342.   if$
  343. }
  344.  
  345. INTEGERS { multiresult }
  346.  
  347. FUNCTION {multi.page.check}
  348. { 't :=
  349.   #0 'multiresult :=
  350.     { multiresult not
  351.       t empty$ not
  352.       and
  353.     }
  354.     { t #1 #1 substring$
  355.       duplicate$ "-" =
  356.       swap$ duplicate$ "," =
  357.       swap$ "+" =
  358.       or or
  359.     { #1 'multiresult := }
  360.     { t #2 global.max$ substring$ 't := }
  361.       if$
  362.     }
  363.   while$
  364.   multiresult
  365. }
  366.  
  367. FUNCTION {format.pages}
  368. { pages empty$
  369.     { "" }
  370.     { pages multi.page.check
  371.     { "pages" pages n.dashify tie.or.space.connect }
  372.     { "page" pages tie.or.space.connect }
  373.       if$
  374.     }
  375.   if$
  376. }
  377.  
  378. FUNCTION {format.vol.num.pages}
  379. { volume field.or.null
  380.   number empty$
  381.     'skip$
  382.     { "(" number * ")" * *
  383.       volume empty$
  384.     { "there's a number but no volume in " cite$ * warning$ }
  385.     'skip$
  386.       if$
  387.     }
  388.   if$
  389.   pages empty$
  390.     'skip$
  391.     { duplicate$ empty$
  392.     { pop$ format.pages }
  393.     { ":" * pages n.dashify * }
  394.       if$
  395.     }
  396.   if$
  397. }
  398.  
  399. FUNCTION {format.chapter.pages}
  400. { chapter empty$
  401.     'format.pages
  402.     { type empty$
  403.     { "chapter" }
  404.     { type "l" change.case$ }
  405.       if$
  406.       chapter tie.or.space.connect
  407.       pages empty$
  408.     'skip$
  409.     { ", " * format.pages * }
  410.       if$
  411.     }
  412.   if$
  413. }
  414.  
  415. FUNCTION {format.in.ed.booktitle}
  416. { booktitle empty$
  417.     { "" }
  418.     { editor empty$
  419.     { "In " booktitle emphasize * }
  420.     { "In " format.editors * ", " * booktitle emphasize * }
  421.       if$
  422.     }
  423.   if$
  424. }
  425.  
  426. FUNCTION {empty.misc.check}
  427. { author empty$ title empty$ howpublished empty$
  428.   month empty$ year empty$ note empty$
  429.   and and and and and
  430.   key empty$ not and
  431.     { "all relevant fields are empty in " cite$ * warning$ }
  432.     'skip$
  433.   if$
  434. }
  435.  
  436. FUNCTION {format.thesis.type}
  437. { type empty$
  438.     'skip$
  439.     { pop$
  440.       type "t" change.case$
  441.     }
  442.   if$
  443. }
  444.  
  445. FUNCTION {format.tr.number}
  446. { type empty$
  447.     { "Technical Report" }
  448.     'type
  449.   if$
  450.   number empty$
  451.     { "t" change.case$ }
  452.     { number tie.or.space.connect }
  453.   if$
  454. }
  455.  
  456. FUNCTION {format.article.crossref}
  457. { key empty$
  458.     { journal empty$
  459.     { "need key or journal for " cite$ * " to crossref " * crossref *
  460.       warning$
  461.       ""
  462.     }
  463.     { "In {\em " journal * "\/}" * }
  464.       if$
  465.     }
  466.     { "In " key * }
  467.   if$
  468.   " \cite{" * crossref * "}" *
  469. }
  470.  
  471. FUNCTION {format.crossref.editor}
  472. { editor #1 "{vv~}{ll}" format.name$
  473.   editor num.names$ duplicate$
  474.   #2 >
  475.     { pop$ " et~al." * }
  476.     { #2 <
  477.     'skip$
  478.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  479.         { " et~al." * }
  480.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  481.       if$
  482.     }
  483.       if$
  484.     }
  485.   if$
  486. }
  487.  
  488. FUNCTION {format.book.crossref}
  489. { volume empty$
  490.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  491.       "In "
  492.     }
  493.     { "Volume" volume tie.or.space.connect
  494.       " of " *
  495.     }
  496.   if$
  497.   editor empty$
  498.   editor field.or.null author field.or.null =
  499.   or
  500.     { key empty$
  501.     { series empty$
  502.         { "need editor, key, or series for " cite$ * " to crossref " *
  503.           crossref * warning$
  504.           "" *
  505.         }
  506.         { "{\em " * series * "\/}" * }
  507.       if$
  508.     }
  509.     { key * }
  510.       if$
  511.     }
  512.     { format.crossref.editor * }
  513.   if$
  514.   " \cite{" * crossref * "}" *
  515. }
  516.  
  517. FUNCTION {format.incoll.inproc.crossref}
  518. { editor empty$
  519.   editor field.or.null author field.or.null =
  520.   or
  521.     { key empty$
  522.     { booktitle empty$
  523.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  524.           crossref * warning$
  525.           ""
  526.         }
  527.         { "In {\em " booktitle * "\/}" * }
  528.       if$
  529.     }
  530.     { "In " key * }
  531.       if$
  532.     }
  533.     { "In " format.crossref.editor * }
  534.   if$
  535.   " \cite{" * crossref * "}" *
  536. }
  537.  
  538. FUNCTION {article}
  539. { output.bibitem
  540.   format.authors "author" output.check
  541.   new.block
  542.   format.title "title" output.check
  543.   new.block
  544.   crossref missing$
  545.     { journal emphasize "journal" output.check
  546.       format.vol.num.pages output
  547.       format.date "year" output.check
  548.     }
  549.     { format.article.crossref output.nonnull
  550.       format.pages output
  551.     }
  552.   if$
  553.   new.block
  554.   note output
  555.   fin.entry
  556. }
  557.  
  558. FUNCTION {book}
  559. { output.bibitem
  560.   author empty$
  561.     { format.editors "author and editor" output.check }
  562.     { format.authors output.nonnull
  563.       crossref missing$
  564.     { "author and editor" editor either.or.check }
  565.     'skip$
  566.       if$
  567.     }
  568.   if$
  569.   new.block
  570.   format.btitle "title" output.check
  571.   crossref missing$
  572.     { format.bvolume output
  573.       new.block
  574.       format.number.series output
  575.       new.sentence
  576.       publisher "publisher" output.check
  577.       address output
  578.     }
  579.     { new.block
  580.       format.book.crossref output.nonnull
  581.     }
  582.   if$
  583.   format.edition output
  584.   format.date "year" output.check
  585.   new.block
  586.   note output
  587.   fin.entry
  588. }
  589.  
  590. FUNCTION {booklet}
  591. { output.bibitem
  592.   format.authors output
  593.   new.block
  594.   format.title "title" output.check
  595.   howpublished address new.block.checkb
  596.   howpublished output
  597.   address output
  598.   format.date output
  599.   new.block
  600.   note output
  601.   fin.entry
  602. }
  603.  
  604. FUNCTION {inbook}
  605. { output.bibitem
  606.   author empty$
  607.     { format.editors "author and editor" output.check }
  608.     { format.authors output.nonnull
  609.       crossref missing$
  610.     { "author and editor" editor either.or.check }
  611.     'skip$
  612.       if$
  613.     }
  614.   if$
  615.   new.block
  616.   format.btitle "title" output.check
  617.   crossref missing$
  618.     { format.bvolume output
  619.       format.chapter.pages "chapter and pages" output.check
  620.       new.block
  621.       format.number.series output
  622.       new.sentence
  623.       publisher "publisher" output.check
  624.       address output
  625.     }
  626.     { format.chapter.pages "chapter and pages" output.check
  627.       new.block
  628.       format.book.crossref output.nonnull
  629.     }
  630.   if$
  631.   format.edition output
  632.   format.date "year" output.check
  633.   new.block
  634.   note output
  635.   fin.entry
  636. }
  637.  
  638. FUNCTION {incollection}
  639. { output.bibitem
  640.   format.authors "author" output.check
  641.   new.block
  642.   format.title "title" output.check
  643.   new.block
  644.   crossref missing$
  645.     { format.in.ed.booktitle "booktitle" output.check
  646.       format.bvolume output
  647.       format.number.series output
  648.       format.chapter.pages output
  649.       new.sentence
  650.       publisher "publisher" output.check
  651.       address output
  652.       format.edition output
  653.       format.date "year" output.check
  654.     }
  655.     { format.incoll.inproc.crossref output.nonnull
  656.       format.chapter.pages output
  657.     }
  658.   if$
  659.   new.block
  660.   note output
  661.   fin.entry
  662. }
  663.  
  664. FUNCTION {inproceedings}
  665. { output.bibitem
  666.   format.authors "author" output.check
  667.   new.block
  668.   format.title "title" output.check
  669.   new.block
  670.   crossref missing$
  671.     { format.in.ed.booktitle "booktitle" output.check
  672.       format.bvolume output
  673.       format.number.series output
  674.       format.pages output
  675.       address empty$
  676.     { organization publisher new.sentence.checkb
  677.       organization output
  678.       publisher output
  679.       format.date "year" output.check
  680.     }
  681.     { address output.nonnull
  682.       format.date "year" output.check
  683.       new.sentence
  684.       organization output
  685.       publisher output
  686.     }
  687.       if$
  688.     }
  689.     { format.incoll.inproc.crossref output.nonnull
  690.       format.pages output
  691.     }
  692.   if$
  693.   new.block
  694.   note output
  695.   fin.entry
  696. }
  697.  
  698. FUNCTION {conference} { inproceedings }
  699.  
  700. FUNCTION {manual}
  701. { output.bibitem
  702.   author empty$
  703.     { organization empty$
  704.     'skip$
  705.     { organization output.nonnull
  706.       address output
  707.     }
  708.       if$
  709.     }
  710.     { format.authors output.nonnull }
  711.   if$
  712.   new.block
  713.   format.btitle "title" output.check
  714.   author empty$
  715.     { organization empty$
  716.     { address new.block.checka
  717.       address output
  718.     }
  719.     'skip$
  720.       if$
  721.     }
  722.     { organization address new.block.checkb
  723.       organization output
  724.       address output
  725.     }
  726.   if$
  727.   format.edition output
  728.   format.date output
  729.   new.block
  730.   note output
  731.   fin.entry
  732. }
  733.  
  734. FUNCTION {mastersthesis}
  735. { output.bibitem
  736.   format.authors "author" output.check
  737.   new.block
  738.   format.title "title" output.check
  739.   new.block
  740.   "Master's thesis" format.thesis.type output.nonnull
  741.   school "school" output.check
  742.   address output
  743.   format.date "year" output.check
  744.   new.block
  745.   note output
  746.   fin.entry
  747. }
  748.  
  749. FUNCTION {misc}
  750. { output.bibitem
  751.   format.authors output
  752.   title howpublished new.block.checkb
  753.   format.title output
  754.   howpublished new.block.checka
  755.   howpublished output
  756.   format.date output
  757.   new.block
  758.   note output
  759.   fin.entry
  760.   empty.misc.check
  761. }
  762.  
  763. FUNCTION {phdthesis}
  764. { output.bibitem
  765.   format.authors "author" output.check
  766.   new.block
  767.   format.btitle "title" output.check
  768.   new.block
  769.   "PhD thesis" format.thesis.type output.nonnull
  770.   school "school" output.check
  771.   address output
  772.   format.date "year" output.check
  773.   new.block
  774.   note output
  775.   fin.entry
  776. }
  777.  
  778. FUNCTION {proceedings}
  779. { output.bibitem
  780.   editor empty$
  781.     { organization output }
  782.     { format.editors output.nonnull }
  783.   if$
  784.   new.block
  785.   format.btitle "title" output.check
  786.   format.bvolume output
  787.   format.number.series output
  788.   address empty$
  789.     { editor empty$
  790.     { publisher new.sentence.checka }
  791.     { organization publisher new.sentence.checkb
  792.       organization output
  793.     }
  794.       if$
  795.       publisher output
  796.       format.date "year" output.check
  797.     }
  798.     { address output.nonnull
  799.       format.date "year" output.check
  800.       new.sentence
  801.       editor empty$
  802.     'skip$
  803.     { organization output }
  804.       if$
  805.       publisher output
  806.     }
  807.   if$
  808.   new.block
  809.   note output
  810.   fin.entry
  811. }
  812.  
  813. FUNCTION {techreport}
  814. { output.bibitem
  815.   format.authors "author" output.check
  816.   new.block
  817.   format.title "title" output.check
  818.   new.block
  819.   format.tr.number output.nonnull
  820.   institution "institution" output.check
  821.   address output
  822.   format.date "year" output.check
  823.   new.block
  824.   note output
  825.   fin.entry
  826. }
  827.  
  828. FUNCTION {unpublished}
  829. { output.bibitem
  830.   format.authors "author" output.check
  831.   new.block
  832.   format.title "title" output.check
  833.   new.block
  834.   note "note" output.check
  835.   format.date output
  836.   fin.entry
  837. }
  838.  
  839. FUNCTION {default.type} { misc }
  840.  
  841. MACRO {jan} {"January"}
  842.  
  843. MACRO {feb} {"February"}
  844.  
  845. MACRO {mar} {"March"}
  846.  
  847. MACRO {apr} {"April"}
  848.  
  849. MACRO {may} {"May"}
  850.  
  851. MACRO {jun} {"June"}
  852.  
  853. MACRO {jul} {"July"}
  854.  
  855. MACRO {aug} {"August"}
  856.  
  857. MACRO {sep} {"September"}
  858.  
  859. MACRO {oct} {"October"}
  860.  
  861. MACRO {nov} {"November"}
  862.  
  863. MACRO {dec} {"December"}
  864.  
  865. MACRO {acmcs} {"ACM Computing Surveys"}
  866.  
  867. MACRO {acta} {"Acta Informatica"}
  868.  
  869. MACRO {cacm} {"Communications of the ACM"}
  870.  
  871. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  872.  
  873. MACRO {ibmsj} {"IBM Systems Journal"}
  874.  
  875. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  876.  
  877. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  878.  
  879. MACRO {ieeetcad}
  880.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  881.  
  882. MACRO {ipl} {"Information Processing Letters"}
  883.  
  884. MACRO {jacm} {"Journal of the ACM"}
  885.  
  886. MACRO {jcss} {"Journal of Computer and System Sciences"}
  887.  
  888. MACRO {scp} {"Science of Computer Programming"}
  889.  
  890. MACRO {sicomp} {"SIAM Journal on Computing"}
  891.  
  892. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  893.  
  894. MACRO {tods} {"ACM Transactions on Database Systems"}
  895.  
  896. MACRO {tog} {"ACM Transactions on Graphics"}
  897.  
  898. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  899.  
  900. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  901.  
  902. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  903.  
  904. MACRO {tcs} {"Theoretical Computer Science"}
  905.  
  906. READ
  907.  
  908. FUNCTION {sortify}
  909. { purify$
  910.   "l" change.case$
  911. }
  912.  
  913. INTEGERS { len }
  914.  
  915. FUNCTION {chop.word}
  916. { 's :=
  917.   'len :=
  918.   s #1 len substring$ =
  919.     { s len #1 + global.max$ substring$ }
  920.     's
  921.   if$
  922. }
  923.  
  924. FUNCTION {sort.format.names}
  925. { 's :=
  926.   #1 'nameptr :=
  927.   ""
  928.   s num.names$ 'numnames :=
  929.   numnames 'namesleft :=
  930.     { namesleft #0 > }
  931.     { nameptr #1 >
  932.     { "   " * }
  933.     'skip$
  934.       if$
  935.       s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
  936.       nameptr numnames = t "others" = and
  937.     { "et al" * }
  938.     { t sortify * }
  939.       if$
  940.       nameptr #1 + 'nameptr :=
  941.       namesleft #1 - 'namesleft :=
  942.     }
  943.   while$
  944. }
  945.  
  946. FUNCTION {sort.format.title}
  947. { 't :=
  948.   "A " #2
  949.     "An " #3
  950.       "The " #4 t chop.word
  951.     chop.word
  952.   chop.word
  953.   sortify
  954.   #1 global.max$ substring$
  955. }
  956.  
  957. FUNCTION {author.sort}
  958. { author empty$
  959.     { key empty$
  960.     { "to sort, need author or key in " cite$ * warning$
  961.       ""
  962.     }
  963.     { key sortify }
  964.       if$
  965.     }
  966.     { author sort.format.names }
  967.   if$
  968. }
  969.  
  970. FUNCTION {author.editor.sort}
  971. { author empty$
  972.     { editor empty$
  973.     { key empty$
  974.         { "to sort, need author, editor, or key in " cite$ * warning$
  975.           ""
  976.         }
  977.         { key sortify }
  978.       if$
  979.     }
  980.     { editor sort.format.names }
  981.       if$
  982.     }
  983.     { author sort.format.names }
  984.   if$
  985. }
  986.  
  987. FUNCTION {author.organization.sort}
  988. { author empty$
  989.     { organization empty$
  990.     { key empty$
  991.         { "to sort, need author, organization, or key in " cite$ * warning$
  992.           ""
  993.         }
  994.         { key sortify }
  995.       if$
  996.     }
  997.     { "The " #4 organization chop.word sortify }
  998.       if$
  999.     }
  1000.     { author sort.format.names }
  1001.   if$
  1002. }
  1003.  
  1004. FUNCTION {editor.organization.sort}
  1005. { editor empty$
  1006.     { organization empty$
  1007.     { key empty$
  1008.         { "to sort, need editor, organization, or key in " cite$ * warning$
  1009.           ""
  1010.         }
  1011.         { key sortify }
  1012.       if$
  1013.     }
  1014.     { "The " #4 organization chop.word sortify }
  1015.       if$
  1016.     }
  1017.     { editor sort.format.names }
  1018.   if$
  1019. }
  1020.  
  1021. FUNCTION {presort}
  1022. { type$ "book" =
  1023.   type$ "inbook" =
  1024.   or
  1025.     'author.editor.sort
  1026.     { type$ "proceedings" =
  1027.     'editor.organization.sort
  1028.     { type$ "manual" =
  1029.         'author.organization.sort
  1030.         'author.sort
  1031.       if$
  1032.     }
  1033.       if$
  1034.     }
  1035.   if$
  1036.   "    "
  1037.   *
  1038.   year field.or.null sortify
  1039.   *
  1040.   "    "
  1041.   *
  1042.   title field.or.null
  1043.   sort.format.title
  1044.   *
  1045.   #1 entry.max$ substring$
  1046.   'sort.key$ :=
  1047. }
  1048.  
  1049. ITERATE {presort}
  1050.  
  1051. SORT
  1052.  
  1053. STRINGS { longest.label }
  1054.  
  1055. INTEGERS { number.label longest.label.width }
  1056.  
  1057. FUNCTION {initialize.longest.label}
  1058. { "" 'longest.label :=
  1059.   #1 'number.label :=
  1060.   #0 'longest.label.width :=
  1061. }
  1062.  
  1063. FUNCTION {longest.label.pass}
  1064. { number.label int.to.str$ 'label :=
  1065.   number.label #1 + 'number.label :=
  1066.   label width$ longest.label.width >
  1067.     { label 'longest.label :=
  1068.       label width$ 'longest.label.width :=
  1069.     }
  1070.     'skip$
  1071.   if$
  1072. }
  1073.  
  1074. EXECUTE {initialize.longest.label}
  1075.  
  1076. ITERATE {longest.label.pass}
  1077.  
  1078. FUNCTION {begin.bib}
  1079. { preamble$ empty$
  1080.     'skip$
  1081.     { preamble$ write$ newline$ }
  1082.   if$
  1083.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  1084. }
  1085.  
  1086. EXECUTE {begin.bib}
  1087.  
  1088. EXECUTE {init.state.consts}
  1089.  
  1090. ITERATE {call.type$}
  1091.  
  1092. FUNCTION {end.bib}
  1093. { newline$
  1094.   "\end{thebibliography}" write$ newline$
  1095. }
  1096.  
  1097. EXECUTE {end.bib}
  1098.